<?php
/*ѯĵ*/
 include("../../funcs/funcs.php");
 $connect=localConnectUsm();
 $today=date('Y-m-d');
 $tiaojian="";
 $id=trim($_GET['id']);
 $schoolcode = isset($_GET['schoolcode'])?$_GET['schoolcode']:"";
 $area = isset($_GET['area'])?$_GET['area']:"";
 $subid = isset($_GET['subid'])?$_GET['subid']:"";
 $revnum = isset($_GET['revnum'])?$_GET['revnum']:"";
 if($schoolcode!=""){
   $tiaojian="and schoolcode='".$schoolcode."'";
 }
 if($area!=""){
   $tiaojian.=" and area='".$area."'";
 }
 if($revnum!=""){
   $tiaojian.=" and mt <'".$revnum."'";
 }
 $sendonce=trim($_GET['sendonce']);
  if($sendonce==1){
      if($subid=="")//ȫλ
           $sql="select count(*)as num from orderuserinfo where UseSrvID='".$id."' and isorder in(1,2) and  (curRecTime<'$today'or curRecTime is NULL)".($tiaojian==''?'':$tiaojian);
      else
          $sql="select count(*)as num from orderuserinfo where UseSrvID='".$id."' and isorder in(1,2) and  (curRecTime<'$today'or curRecTime is NULL)".($tiaojian==''?'':$tiaojian)."and mp in(select mp from orderpostuser where  subsrvid='".$subid."')";

    }
  else{
       if($subid=="")//ȫλ
           $sql="select count(*)as num from orderuserinfo where UseSrvID='".$id."' and isorder in(1,2)".($tiaojian==''?'':$tiaojian);
       else
            $sql="select count(*)as num from orderuserinfo where UseSrvID='".$id."' and isorder in(1,2)".($tiaojian==''?'':$tiaojian)."and mp in(select mp from orderpostuser where  subsrvid='".$subid."')";
      }
 $query=mssql_query($sql);
 $row=mssql_fetch_array($query);
 mssql_close();
 echo $row['num'];


?>